{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "reduced-conditions",
   "metadata": {},
   "outputs": [],
   "source": [
    "lst1=[\"Krish\",\"Sam\",\"John\"]\n",
    "lst2=[\"a\",'b','c']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "happy-device",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Krish\n",
      "Sam\n",
      "John\n"
     ]
    }
   ],
   "source": [
    "for i in lst1:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "parental-birthday",
   "metadata": {},
   "outputs": [],
   "source": [
    "output=zip(lst1,lst2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "trained-gross",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<zip at 0x25f925be840>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "output"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "right-portal",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('Krish', 'a'), ('Sam', 'b'), ('John', 'c')]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "unlikely-therapy",
   "metadata": {},
   "outputs": [
    {
     "ename": "StopIteration",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mStopIteration\u001b[0m                             Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-27-c1356355431d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m### zip object is an iterator\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mnext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0moutput\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mStopIteration\u001b[0m: "
     ]
    }
   ],
   "source": [
    "### zip object is an iterator\n",
    "next(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "jewish-production",
   "metadata": {},
   "outputs": [],
   "source": [
    "lst1=[\"Krish\",\"Sam\",\"John\",4]\n",
    "lst2=[\"a\",'b','c']\n",
    "lst3=[1,2,3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "continuous-sender",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Krish a 1\n",
      "Sam b 2\n",
      "John c 3\n"
     ]
    }
   ],
   "source": [
    "output=zip(lst1,lst2,lst3)\n",
    "for i,j,k in output:\n",
    "    print(i,j,k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "continuous-obligation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(zip())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "solar-russia",
   "metadata": {},
   "outputs": [],
   "source": [
    "dict1={'name':'Krish','lst_name':'Naik','age':30}\n",
    "dict2={'name':'Amit','lst_name':'Verma','age':29}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "collect-beauty",
   "metadata": {},
   "outputs": [],
   "source": [
    "dictionary=zip(dict1.items(),dict2.items())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "prime-posting",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'Krish', 'lst_name': 'Naik', 'age': 30}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "demanding-monroe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name Krish\n",
      "name Amit\n",
      "lst_name Naik\n",
      "lst_name Verma\n",
      "age 30\n",
      "age 29\n"
     ]
    }
   ],
   "source": [
    "for (i,j),(i2,j2) in dictionary:\n",
    "    print(i, j)\n",
    "    print(i2,j2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "christian-registrar",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "infrared-carrier",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "occupied-graphics",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "plastic-richardson",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "constitutional-federation",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "global-label",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "agreed-compensation",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "threaded-means",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
